package com.boho.ecp.manage.service.param;

import java.sql.Connection;
import java.util.HashMap;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import cn.boho.framework.connection.ConnectionHelper;
import cn.boho.framework.po.DynaBeanMap;
import cn.boho.framework.service.Service;

import com.boho.ecp.constant.Product;
import com.boho.ecp.manage.service.param.dao.ParamDao;

public class ParamService implements Service{

	 private static Logger logger = LogManager.getLogger(ParamService.class.getName());
	
	public void destory() throws Exception {
		
	}

	public String getName() {
		return null;
	}

	public void initialize(HashMap paramHashMap){
		String sStartService = (String)paramHashMap.get("StartService");
		if (!(sStartService.equalsIgnoreCase("true"))){
			return;
		}
		paramHashMap.remove("StartService");
		logger.info("系统参数服务启动");
		
		Connection con = null;
		try {
			con = ConnectionHelper.getConnection();
			DynaBeanMap dbm = ParamDao.getParamByName(con, "point");
			String val = (String)dbm.get("SYSTEM_PARA_VALUES");
			Product.POINT_RATE = Integer.parseInt(val);
		} catch (Exception e) {
			logger.error("参数初始化异常", e);
		} finally{
			ConnectionHelper.finalRelease(con);
		}
		
	}

}
